﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Skyhook.AI.PathFinder
{
    static class PathNodeStates
    {
        public const int None = 0;
        public const int Open = 1;
        public const int Closed = 2;
    }
    struct PathNode
    {
        static public int StateShift = 0;
        public int F;
        public int G;
        public int H;
        public int ParentDirection;
        public int State;
        public PointData Data;

        public void SetPermanentlyClosedNode()
        {
            State = int.MaxValue;
        }
        public void SetClosedNode()
        {
            State = PathNodeStates.Closed + StateShift;
        }
        public void Clear()
        {
            State = PathNodeStates.None + StateShift;
            Data = null;
        }
        public void SetOpenedNode(int fromparentdirection, int parentg, int h)
        {
            ParentDirection = fromparentdirection;

            if (ParentDirection == MoveDirection.E || ParentDirection == MoveDirection.N ||
                ParentDirection == MoveDirection.S || ParentDirection == MoveDirection.W)
            {
                G = parentg + 3;
            }
            else
            if (ParentDirection == MoveDirection.Unknown)
            {
                G = 0;
            }
            else
            {
                G = parentg + 2;
            }

            H = h;
            F = G + H;

            State = PathNodeStates.Open + StateShift;
        }
    }
}
